<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="root"></div>
<script src="../../javascript/react.development.js"></script>
<script src="../../javascript/react-dom.development.js"></script>
<!--引入prop-types用于对props的类型进行限制-->
<script src="../../javascript/prop-types.js"></script>
<script src="../../javascript/babel.min.js"></script>

<script type="text/babel">
    class Person extends React.Component {
        constructor(props, context) {
            super(props, context)
        }

        render() {
            const {name, age, sex} = this.props
            return (
                <div className="app">
                    <ul>
                        <li>姓名是：{name}</li>
                        <li>年龄是：{age}</li>
                        <li>性别是：{sex}</li>
                    </ul>
                </div>
            );
        }
    }
    // 对props的值进行类型和必要性的限制
    Person.propTypes = {
        name: PropTypes.string.isRequired,
        age: PropTypes.number.isRequired,
        getAge:PropTypes.func
    }
    // 对props的值进行默认值的指定
    Person.defaultProps = {
        sex: "男"
    }

    ReactDOM.render(<Person name="陶品奇" age={22} sex="男"></Person>, document.querySelector("#root"))

</script>
</body>
</html>